<?php

declare(strict_types=1);

namespace App\CustHub\Listener;

use App\CustHub\Event\RobotLoginAfter;
use App\CustHub\Event\RoomBroadcastTrigger;
use App\CustHub\Service\ChRoomBroadcastService;
use Hyperf\Event\Annotation\Listener;
use Hyperf\Event\Contract\ListenerInterface;
use Psr\Container\ContainerInterface;

#[Listener]
class RoomBroadcastListener implements ListenerInterface
{

    protected $container;

    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    public function listen(): array
    {
        return [
            RoomBroadcastTrigger::class,
        ];
    }

    public function process(object $event): void
    {
        container()->get(ChRoomBroadcastService::class)->handle($event->robot,$event->data);
    }
}